// #include <stdio.h>
// #include <unistd.h>
// #include <string.h>

// #include "ohos_init.h"
// #include "cmsis_os2.h"
// #include "hal_bsp_ssd1306.h"
// #include "hal_bsp_pcf8574.h"

// #include "oled_show.h"

#include "sys_config.h"

uint8_t oledShowBuff[20] = {0};

void oled_show(char *str, int num, int line)
{
    strncpy(oledShowBuff, str, num);
    SSD1306_ShowStr(OLED_TEXT16_COLUMN_0, line, oledShowBuff, TEXT_SIZE_16);
}

/**
 * @brief 更新OLED的显示
 * @note 取出全局变量结构体的内容，显示本地IP，客户端数量，电压，距离，左右轮速
 * @param {*}
 * @return {*}
 */
void Oled_Update_Carstatus(void)
{
    SSD1306_ShowStr(OLED_TEXT16_COLUMN_0, 0, globals_car_status.local_ip_address, TEXT_SIZE_16);

    memset(oledShowBuff, 0, 20);
    sprintf(oledShowBuff, "P:%2d, D:%3d", globals_car_status.power, globals_car_status.distance);
    printf("oled:%s\r\n", oledShowBuff);
    SSD1306_ShowStr(OLED_TEXT16_COLUMN_0, 2, oledShowBuff, TEXT_SIZE_16);

    memset(oledShowBuff, 0, 20);
    sprintf(oledShowBuff, "L_S=%2d, R_S=%2d", globals_car_status.left_speed, globals_car_status.right_speed);
    printf("oled:%s\r\n", oledShowBuff);
    SSD1306_ShowStr(OLED_TEXT16_COLUMN_0, 3, oledShowBuff, TEXT_SIZE_16);
}
